import { defineStore } from 'pinia'
export const userStore = defineStore('userStore', {
    state: () => {
        return {
            profile: {
                id: '',
                account: '',
                avatar: '',
                nickname: '',
                account: '',
                mobile: '',
                token: '',
                city: '',
            },
        }
    },
    actions: {
        // 设置用户信息
        setUser(payload) {
            this.profile = payload
        },
        // 修改用户信息
        updateUser(obj) {
            this.profile = { ...this.profile, ...obj }
        },
    },
    persist: {
        // 开启数据持久化
        enabled: true,
        strategies: [
            {
                // 保存的名称
                key: 'useManage',
                storage: localStorage,
            },
        ],
    },
})
